package com.dfbz.demo01_实现TCP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo03_发送端 {
    public static void main(String[] args) throws Exception {

        // 创建了一个UDP报文的发送/接收器
        DatagramSocket socket = new DatagramSocket();

        // 封装一个UDP报文
        DatagramPacket packet = new DatagramPacket(
                "ab".getBytes(),
                "ab".getBytes().length,
                InetAddress.getByName("localhost"),
                8989
        );

        socket.send(packet);

        socket.close();
    }
}
